package com.example.cron.task;

import com.example.cron.jpa.OrderMainRepository;
import com.example.cron.service.InquireTask;
import com.example.cron.service.RecipeTask;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class Worker {
    @Resource
    private InquireTask inquireTask;
    @Resource
    private RecipeTask recipeTask;
    // 5分钟 结束未接诊超时会话，自动退款
    @Scheduled(fixedDelay= 5 * 60 * 1000)
    public void FinToBeReceive(){
        inquireTask.cancelTimeOutInquireOrder();
    }

    // 5分钟 结束问诊中超时会话
    @Scheduled(fixedDelay= 5 * 60 * 1000)
    public void FinInquiry(){
        inquireTask.cancelTimeOutSessionOrder();
    }

    // 00:07 处方失效（3天自然日：包含开方当天在内3天；第3天24点失效）
    @Scheduled(cron="0 7 0 * * ?")
    public void IsRxExpired(){
        recipeTask.cancelTimeOutRecipe();
    }

    // 1:07 已结束的视频，语音问诊，文件下载
    @Scheduled(cron="1 7 0 * * ?")
    public void downLoad(){
        inquireTask.downLoadAudiovideo();
    }
}
